import request from '@/api/request'
/**登陆 */
export const login = ({ username, password }) =>
  request({
    url: `/api/user/login`,
    method: 'post',
    data: {
      username,
      password,
    },
  })
/**获取我的信息 */
export const getme = () =>
  request({
    url: `/api/user/me`,
    method: 'get',
  })
/**验证码 */
export const authCode = ({ mail }) =>
  request({
    url: `/api/user/auth-code`,
    method: 'get',
    params: {
      mail,
    },
  })

/**注册 */
export const enroll = ({ username, password, mail, authCode }) =>
  request({
    url: `/api/user/enroll`,
    method: 'post',
    data: {
      username,
      password,
      mail,
      authCode,
    },
  })
/**验证码是否有效 */
export const verifycode = ({ mail, authCode }) =>
  request({
    url: `/api/user/verifycode`,
    method: 'post',
    data: {
      mail,
      authCode,
    },
  })

/**用户名是否有效 */
export const username = ({ username }) =>
  request({
    url: `/api/user/username`,
    method: 'get',
    params: {
      username,
    },
  })

/**修改用户名 */
export const myusername = ({ username }) =>
  request({
    url: `/api/user/modifyname`,
    method: 'post',
    data: {
      username,
    },
  })
/**修改头像 */
export const myportrait = ({ portrait }) =>
  request({
    url: `/api/user/portrait`,
    method: 'post',
    data: {
      portrait,
    },
  })
